package com.example.springcloudwinter.controller;

import com.example.springcloudwinter.dto.ResultEntity;
import com.example.springcloudwinter.po.OrderPo;
import com.example.springcloudwinter.service.PointService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.*;

import java.sql.SQLException;

@RefreshScope
@RestController
@RequestMapping("/point")
public class PointController {
    
    @Autowired
    private PointService pointsService;
    
    @GetMapping("/record")
    public ResultEntity<?> listPointsByUserId (@RequestParam("userId") String userId){
        return pointsService.listPoints(userId);
    }
    
    @PostMapping("/PayPoint")
    public ResultEntity<?> payPoint (@RequestParam("orderPo") OrderPo orderPo,@RequestParam("userId")String userId) throws SQLException {
        return pointsService.payPoint(orderPo,userId);
    }
}
